<h3>发货打印配置</h3>
<div class="gridlist-action data-action" id="dataAction" style="margin-bottom:10px;padding:5px; border:0;">
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td nowrap="nowrap" style="width:auto;">
			<div class="tabs-wrap select-tabs delivery-cfg-tab">
			<ul style="margin-top:2px;padding:0;">
				<li class="tab current" >
					<span><a href="javascript:void(0);"><{t}>基本配置<{/t}></a></span>
				</li>
                
				<li class="tab " <{if $basic_cfg}>style="display:none;"<{/if}>>
					<span><a href="javascript:void(0);"><{t}>单品打印配置<{/t}></a></span>
				</li>
				<li class="tab " <{if $basic_cfg}>style="display:none;"<{/if}>>
					<span><a href="javascript:void(0);"><{t}>多品打印配置<{/t}></a></span>
				</li>
			</ul>
			</div>
		</td>
	</tr>
	</table>
</div>
<form action='index.php?app=wms&ctl=admin_delivery_cfg&act=save' method='post'>
<!--基本配置-->
<div class='delivery-cfg-item'>
	<div class='tableform'>
		<div class="division">
			<table width="100%" cellspacing="0" cellpadding="0" border="0" class='delivery-cfg-table'>
				<tbody>
				<tr>
					<th><{t}>批量打印数量：<{/t}></th>
					<td>
						<{input type="text" vtype="required&&unsignedint" name="set[wms_batch_print_nums]"  value=$data.wms_batch_print_nums|default:100 }>
						<{help}>批量打印单据数量上限<{/help}>
					</td>
				</tr>
				</tbody>
			</table>
            <table width="100%" cellspacing="0" cellpadding="0" border="0" class='delivery-cfg-table' >
                <tbody>
				<tr>
					<th><{t}>备货单：<{/t}></th>
					<td>
						<{input  type="radio"  name="set[stock]" class="delivery-cfg-stock" options=$setting.stock.options separator='&nbsp;' value=$data.stock|default:'1' }>
						<{help}>用于仓库拣货，可以将所选发货单按商品进行分组，提升拣货效率，特别适用于2次分拣<{/help}>
						<span class='relate-span'>
						备货单商品名称：
						<{input type="select" name="set[wms_delivery_is_printstock]" options=$setting.wms_delivery_is_printstock.options value=$data.wms_delivery_is_printstock|default:'2' required='required' }>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>发货单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[delie]" class="delivery-cfg-delie" options=$setting.delie.options separator='&nbsp;' value=$data.delie|default:'1' }>
						<{help}>又叫做购物清单，是给客户的购物凭证,可以在反面印刷退换货表格，建议使用激光打印机。<{/help}>
						<span class='relate-span'>
						发货单商品名称：
						<{input type="select" name="set[wms_delivery_is_printdelivery]" options=$setting.wms_delivery_is_printdelivery.options value=$data.wms_delivery_is_printdelivery|default:'2' required='required' }>
                        &nbsp;&nbsp;&nbsp;<{input type="radio"  name="set[print_order]" options=$setting.print_order.options separator='&nbsp;' value=$data.print_order|default:'0'}>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>联合单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[merge]" class="delivery-cfg-merge" options=$setting.merge.options separator='&nbsp;' value=$data.merge|default:'1' }>
						<{help}>主要用于2次分拣，先打分组备货单再打发货单。例如一次打100单，分组是20，就会先打1-20的备货单，再打1-20的发货单；21-40的备货单....<{/help}>
						<span class='relate-span'>
						联合单商品名称：
						<{input type="select" name="set[wms_delivery_merge_print]" options=$setting.wms_delivery_merge_print.options value=$data.wms_delivery_merge_print|default:'2' required='required' }>
						&nbsp;联合打印分组数：<{input type="text" name="set[wms_eachgroup_print_count]" value=$data.wms_eachgroup_print_count|default:20 vtype="unsignedint" size="4"}>
						<{help}>该值可根据手推车格子数来设定。<{/help}>
						</span>
					</td>
				</tr>
                </tbody>
            </table>
			<table width="100%" cellspacing="0" cellpadding="0" border="0" class='delivery-cfg-table'>
				<tbody>
				<tr>
					<th><{t}>快递单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[expre]" options=$setting.expre.options separator='&nbsp;' value=$data.expre|default:'1' disabled=true }>
						<{help}>一般使用针式打印机连续打印。快递单不能选择(必选)。<{/help}>
						<span class='relate-span'>
						快递单商品名称：
						<{input type="select" name="set[wms_delivery_is_printship]" options=$setting.wms_delivery_is_printship.options value=$data.wms_delivery_is_printship|default:'2' required='required' }>
                        &nbsp;&nbsp;&nbsp;<{input type="radio"  name="set[print_pkg_goods]" options=$setting.print_pkg_goods.options separator='&nbsp;' value=$data.print_pkg_goods|default:'0'}>
						</span>
					</td>
				</tr>
    <tr>
				<th><{t}>分销王订单发货人信息：<{/t}></th>
					<td>
						<{input  type="radio"  name="set[wms_delivery_sellagent]" class="delivery-cfg-stock" options=$setting.sellagent.options separator='&nbsp;' value=$data.wms_delivery_sellagent|default:'0' }>
					</td>
				</tr>
				<tr>
					<th><{t}>分组效验：<{/t}></th>
					<td>
						<{input type="radio"  name="set[verify]" options=$setting.verify.options separator='&nbsp;' value=$data.verify|default:'1' }>
						<{help}>开启分组效验<{/help}>
						<span class='relate-span'>发货单分组：<div style="padding-top:5px;width:auto;">
							<{foreach from=$orderTypes item=item key=key}>
								<input type="checkbox"  name="set[wms_delivery_verify_group][<{$item.tid}>]" value="<{$item.tid}>" <{if $data.wms_delivery_verify_group[$item.tid]}>checked<{/if}> /> <{$item.name}>
							<{/foreach}>
							</div>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>分组发货：<{/t}></th>
					<td>
						<{input type="radio"  name="set[consign]" options=$setting.consign.options separator='&nbsp;' value=$data.consign|default:'1' }>
						<{help}>开启分组发货<{/help}>
						<span class='relate-span delivery-group'>发货单分组：<table style="width:auto;">
						<{foreach from=$orderTypes item=item key=key}>
							<tr>
							<td>
							<input type="checkbox" name="set[wms_delivery_consign_group][<{$item.tid}>]" value="<{$item.tid}>" <{if $data.wms_delivery_consign_group[$item.tid]}>checked<{/if}> /> <{$item.name}>
							</td>
							<td>
							重量：<input type="text" name="set[wms_delivery_consign_weight][<{$item.tid}>]" value="<{$data.wms_delivery_consign_weight[$item.tid]}>" size="5" />克
							</td>
							</tr>
						<{/foreach}>
						</table></span>
					</td>
				</tr>
				<tr>
					<th><{t}>打印格式：<{/t}></th>
					<td>
						<{input type="radio"  name="set[wms_delivery_print_style]" options=$setting.print_style.options separator='&nbsp;' value=$data.wms_delivery_print_style|default:'1'}>

						
					</td>
				</tr>
    			<tr>
					<th><{t}>打印版本：<{/t}></th>
					<td>
						<{input type="radio"  class='delivery_print_version' name="set[wms_delivery_print_devision]" options=$setting.print_devision.options separator='&nbsp;' value=$data.wms_delivery_print_devision}>

						<{help}>旧模版（只可用html编辑，默认不显示捆绑商品明细）
						新模版（增加支持控件编辑，默认展示捆绑商品明细）<{/help}>
					</td>
				</tr>
				<!-- 以下是开启发货、备货模式 -->
				
    			<tr>
					<th><{t}>发货打印模板：<{/t}></th>
					<td>
						<{input type="radio"  class='delivery_print_mode' name="set[wms_delivery_print_mode]" options=$setting.print_mode.options separator='&nbsp;' value=$data.wms_delivery_print_mode}>

						
					</td>
				</tr>
                <tr>
                    <th><{t}>备货打印模板：<{/t}></th>
                    <td>
                        <{input type="radio"  class='delivery_print_mode' name="set[wms_stock_print_mode]" options=$setting.stock_print_mode.options separator='&nbsp;' value=$data.wms_stock_print_mode}>


                    </td>
                </tr>
           
				</tbody>
			</table>
		</div>
	</div>
</div>

<!--单品配置-->
<div class='delivery-cfg-item'>
	<!--<div class="error">欲配置该项，先关闭单品、多品混合打印!!!</div>-->
	<div class='tableform  delivery-cfg-single'>
		<div class="division">
			<div class='notice'>单品打印是将单一SKU的发货单集中打印，排列顺序是按照货位，商品，数量，方便拣货。</div>
			<table width="100%" cellspacing="0" cellpadding="0" border="0" class='delivery-cfg-table'>
				<tbody>
				<tr>
					<th><{t}>批量打印数量：<{/t}></th>
					<td>
						<{input type="text" vtype="required&&unsignedint" name="set[single][wms_batch_print_nums]"  value=$data.single.wms_batch_print_nums|default:100 }>
						<{help}>批量打印单据数量上限<{/help}>
					</td>
				</tr>
				<tr>
					<th><{t}>备货单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[single][stock]" class="delivery-cfg-stock" options=$setting.stock.options separator='&nbsp;' value=$data.single.stock|default:'1' }>
						<{help}>用于仓库拣货，可以将所选发货单按商品进行分组，提升拣货效率，特别适用于2次分拣<{/help}>
						<span class='relate-span'>
						备货单商品名称：
						<{input type="select" name="set[single][wms_delivery_is_printstock]" options=$setting.wms_delivery_is_printstock.options value=$data.single.wms_delivery_is_printstock|default:'2' required='required' }>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>发货单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[single][delie]" class="delivery-cfg-delie" options=$setting.delie.options separator='&nbsp;' value=$data.single.delie|default:'1' }>
						<{help}>又叫做购物清单，是给客户的购物凭证,可以在反面印刷退换货表格，建议使用激光打印机。<{/help}>
						<span class='relate-span'>
						发货单商品名称：
						<{input type="select" name="set[single][wms_delivery_is_printdelivery]" options=$setting.wms_delivery_is_printdelivery.options value=$data.single.wms_delivery_is_printdelivery|default:'2' required='required' }>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>联合单：<{/t}></th>
					<td>
						<!--<{input type="radio"  name="set[single][merge]" class="delivery-cfg-merge" options=$setting.merge.options separator='&nbsp;' value=$data.single.merge|default:'1' }>-->
						<{help}>主要用于2次分拣，先打分组备货单再打发货单。例如一次打100单，分组是20，就会先打1-20的备货单，再打1-20的发货单；21-40的备货单....<{/help}>
						<span class='relate-span'>
						联合单商品名称：
						<{input type="select" name="set[single][wms_delivery_merge_print]" options=$setting.wms_delivery_merge_print.options value=$data.single.wms_delivery_merge_print|default:'2' required='required' }>
						&nbsp;联合打印分组数：<{input type="text" name="set[single][wms_eachgroup_print_count]" value=$data.single.wms_eachgroup_print_count|default:20 vtype="unsignedint" size="4"}>
						<{help}>该值可根据手推车格子数来设定。<{/help}>
						</span>
					</td>
				</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>
<!--多品配置-->
<div class='delivery-cfg-item '>
	<!--<div class='error'>欲配置该项，先关闭单品、多品混合打印!!!</div>-->
	<div class='tableform delivery-cfg-multi'>
		<div class="division">
			<div class='notice'>是将多sku发货单集中打印，特别提供为2次分拣设计的联合打印，这样快递单打印100单，如果2次分拣分组为20 则联合打印先输出1-20 的备货单，再打印1-20的发货单；再21-40 的备货单....</div>
			<table width="100%" cellspacing="0" cellpadding="0" border="0" class='delivery-cfg-table'>
				<tbody>
				<tr>
					<th><{t}>批量打印数量：<{/t}></th>
					<td>
						<{input type="text" vtype="required&&unsignedint" name="set[multi][wms_batch_print_nums]"  value=$data.multi.wms_batch_print_nums|default:100 }>
						<{help}>批量打印单据数量上限<{/help}>
					</td>
				</tr>
				<tr>
					<th><{t}>备货单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[multi][stock]" class="delivery-cfg-stock" options=$setting.stock.options separator='&nbsp;' value=$data.multi.stock|default:'1' }>
						<{help}>用于仓库拣货，可以将所选发货单按商品进行分组，提升拣货效率，特别适用于2次分拣<{/help}>
						<span class='relate-span'>
						备货单商品名称：
						<{input type="select" name="set[multi][wms_delivery_is_printstock]" options=$setting.wms_delivery_is_printstock.options value=$data.multi.wms_delivery_is_printstock|default:'2' required='required' }>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>发货单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[multi][delie]" class="delivery-cfg-delie" options=$setting.delie.options separator='&nbsp;' value=$data.multi.delie|default:'1' }>
						<{help}>又叫做购物清单，是给客户的购物凭证,可以在反面印刷退换货表格，建议使用激光打印机。<{/help}>
						<span class='relate-span'>
						发货单商品名称：
						<{input type="select" name="set[multi][wms_delivery_is_printdelivery]" options=$setting.wms_delivery_is_printdelivery.options value=$data.multi.wms_delivery_is_printdelivery|default:'2' required='required' }>
						</span>
					</td>
				</tr>
				<tr>
					<th><{t}>联合单：<{/t}></th>
					<td>
						<{input type="radio"  name="set[multi][merge]" class="delivery-cfg-merge" options=$setting.merge.options separator='&nbsp;' value=$data.multi.merge|default:'1' }>
						<{help}>主要用于2次分拣，先打分组备货单再打发货单。例如一次打100单，分组是20，就会先打1-20的备货单，再打1-20的发货单；21-40的备货单....<{/help}>
						<span class='relate-span'>
						联合单商品名称：
						<{input type="select" name="set[multi][wms_delivery_merge_print]" options=$setting.wms_delivery_merge_print.options value=$data.multi.wms_delivery_merge_print|default:'2' required='required' }>
						&nbsp;联合打印分组数：<{input type="text" name="set[multi][wms_eachgroup_print_count]" value=$data.multi.wms_eachgroup_print_count|default:20 vtype="unsignedint" size="4"}>
						<{help}>该值可根据手推车格子数来设定。<{/help}>
						</span>
					</td>
				</tr>
				</tbody>
			</table>
		</div>
	</div>
</div>
<div class="table-action">
<{button label="提交" type="submit" name="submit" id="btn_submit" }>
</div>
</form>
<script>
window.addEvent('domready',function(e)
{
	if($E('.delivery-cfg-tab li')) new ItemAgg($ES('.delivery-cfg-tab li'),$ES('.delivery-cfg-item'),{
	  activeName:'current',
	  itemsClass:'delivery-cfg-item-cur'
	});

	$ES(".delivery-cfg-item input[type=radio]").addEvent('click',function(){
		var span = this.getNext('.relate-span');
		if ($defined(span))
		{
			if (this.value=='0')
			{
				span.hide();
			}else{
				span.show();
			}
		}
	});

	function showSpan(){
		var radio = this.getParent('tr').getElement("input:checked");
		if (radio.value=='0')
		{
			this.hide();
		}
	}
	$ES(".relate-span").each(function(el){
		var _showSpan = showSpan.bind(el);
		_showSpan();
	});
	if ($defined($ES("input[name^='set[wms_delivery_consign_group]']")))
	{
		$ES("input[name^='set[wms_delivery_consign_group]']").addEvent('click',function(){
			var weight = this.getParent('tr').getElement("input[name^='set[wms_delivery_consign_weight]']");
			if (this.checked)
			{
				weight.set('readonly',false);
			}else{
				weight.set('readonly',true);
				weight.set('value','');
			}
		});

		function writeWeight(){
			var radio = this.getParent('tr').getElement("input:checked");
			if (!radio)
			{
				this.set('readonly',true);
				this.set('value','');
			}
		}
		$ES(".delivery-group input[name^='set[wms_delivery_consign_weight]']").each(function(el){
			var _writeWeight = writeWeight.bind(el);
			_writeWeight();
		});
	}
	function disabledMerge(){
		var parentTable = this.getParent('table');
		var merge = $ES(".delivery-cfg-merge",parentTable);

        if (merge.length==0)
        {  
            return ;
        }

		var delie_value = $E(".delivery-cfg-delie:checked",parentTable).get('value');
		var stock_value = $E(".delivery-cfg-stock:checked",parentTable).get('value');
		if (delie_value==1 || stock_value==1)
		{
			merge.removeProperty('checked');
			merge.each(function(el){
				if (el.value == 0)
				{
					el.set('checked',true);
					el.fireEvent('click');
				}
			});
			//merge.set('disabled','disabled');
		}
		if (stock_value == 0 && delie_value == 0)
		{
			//merge.removeProperty('disabled');
		}
	}

	$ES('.delivery-cfg-table tbody').each(function(item){
		var _disabledMerge = disabledMerge.bind(item);
		_disabledMerge();
	});

	$ES('.delivery-cfg-stock').addEvent('change',function(){
		var _disabledMerge = disabledMerge.bind(this);
		_disabledMerge();
	});
	$ES('.delivery-cfg-delie').addEvent('change',function(){
		var _disabledMerge = disabledMerge.bind(this);
		_disabledMerge();
	});

	function disabledStock(){
		var parentTable = this.getParent('table');
		var stock = $ES(".delivery-cfg-stock",parentTable);
        if (stock.length==0)
        {
            return;
        }
		var merge_value = $E(".delivery-cfg-merge:checked",parentTable).value;
		if (merge_value == 1)
		{
			stock.removeProperty('checked');
			stock.each(function(el){
				if (el.value == 0)
				{
					el.set('checked',true);
					el.fireEvent('click');
				}
			});
			//stock.set('disabled','disabled');
		}else{
			//stock.removeProperty('disabled');
		}
	}
	function disabledDelie(){
		var parentTable = this.getParent('table');
		var delie  = $ES('.delivery-cfg-delie',parentTable);
        if (delie.length==0)
        {
            return;
        }

		var merge_value = $E(".delivery-cfg-merge:checked",parentTable).value;
		if (merge_value == 1)
		{
			delie.removeProperty('checked');
			delie.each(function(el){
				if (el.value == 0)
				{
					el.set('checked',true);
					el.fireEvent('click');
				}
			});
			//delie.set('disabled','disabled');
		}else{
			//delie.removeProperty('disabled');
		}
	}

	$ES('.delivery-cfg-table tbody').each(function(item){
		var _disabledStock = disabledStock.bind(item);
		var _disabledDelie = disabledDelie.bind(item);
		_disabledStock();
		_disabledDelie();
	});
	$ES('.delivery-cfg-merge').addEvent('change',function(){
		var _disabledStock = disabledStock.bind(this);
		var _disabledDelie = disabledDelie.bind(this);
		_disabledStock();
		_disabledDelie();
	});

 $$('.delivery_print_version').addEvent('click',function(){
 confirm('切换打印版本，请备份好现有使用模板，并修改打印发货和联合打印模板重新载入默认，以免影响您的正常打印!');
 });
});
</script>
